package com.act.web;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.act.domain.AdministrationFee;
import com.act.domain.Sumday;
import com.act.dto.PagerDTO;
import com.act.dto.Response;
import com.act.service.api.IAdministrationFeeService;
import com.act.util.LoggerUtil;
import com.act.vo.PagerVo;

/**
* @Desccription:类说明
* @Author: 刘承军
* @E-mail:923050345@qq.com
* @Date:2017年11月13日 下午3:52:16  
*/
@RestController
@RequestMapping("/adminFee")
public class AdministrationFeeController {

	@Resource 
	private IAdministrationFeeService administrationFeeService;
	
	private final Logger LOGGER = Logger.getLogger(AdministrationFeeController.class);	

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public Response add(AdministrationFee administrationFee) {
    	 try {
    		 administrationFeeService.add(administrationFee);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
         }
    	 return Response.fail();
    }	
    
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public Response update(AdministrationFee administrationFee) {
    	 try {
    		 administrationFeeService.update(administrationFee);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
         }
    	 return Response.fail();
    }	
    
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Response delete(@PathVariable int id) {
    	 try {
    		 administrationFeeService.delete(id);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
         }
    	 return Response.fail();
    }	   
    
    @RequestMapping(value = "/get/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Response getById(@PathVariable int id) {
    	 try {
    		 AdministrationFee administrationFee = administrationFeeService.getById(id);
             return Response.success(administrationFee);
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
         }
    	 return Response.fail();
    }	 
    
    @RequestMapping(value = "/get",method = RequestMethod.POST)
    @ResponseBody
    public Response getAll(@RequestBody PagerDTO pagerDTO) {
    	 try {
    		 PagerVo<Map> pagerVo = administrationFeeService.getAll(pagerDTO);
             return Response.success(pagerVo);
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
         }
    	 return Response.fail();
    }    
}
